import { Button, Space } from "antd";
import { CommonFormTypes } from "globalConstants";
import { SaveModelFormContext, useSaveModelFormContext, useSaveModelFormContext1 } from "modelForm/SaveModelFormContext";
import { useContext } from "react";
import styled from "styled-components";

export const AlyHeader = (prop: any) => {
  // 弹窗出不来
  // const { showSaveForm: showSaveModelForm, visible } = useSaveModelFormContext();

  // 弹窗可以出来
  // const { showSaveForm: showSaveModelForm, visible } = useSaveModelFormContext1();
  // 弹窗可以出来
  const { showSaveForm: showSaveModelForm, visible } = useContext(SaveModelFormContext);
  console.log("1: ", visible);
  // 保存图形 loading
  // const saveModelLoading = useSelector(selectSaveModelLoading);

  // const onSaveModelInfo = useCallback(() => {
  //   showSaveModelForm({
  //     type: CommonFormTypes.Add,
  //     visible: true,
  //     initialValues: { a: 1 },
  //     onSave: (values, onClose) => {
  //       console.log(values);
  //     },
  //   });
  // }, [showSaveModelForm]);
  const onSaveModelInfo = () => {
    console.log("alyHeader 调用showSave");

    showSaveModelForm({
      type: CommonFormTypes.Add,
      visible: true,
      initialValues: { a: 1 },
      onSave: (values, onClose) => {
        console.log(values);
      },
    });
  };

  return (
    <Container>
      <Space>
        <Button type="primary" onClick={onSaveModelInfo}>
          保存模型-点击弹出不来
        </Button>
      </Space>
    </Container>
  );
};

const Container = styled.div`
  padding: 0 16px;
`;

export const AlyHeaderContainer = Container;
